import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
	state: {
		imgShowRoad2: "http://localhost:9010", //本地
		fileUploadRoad: process.env.VUE_APP_Address,
		token: '',
		path: "/UserIndex",
		userInfo:JSON.parse(localStorage.getItem('userInfo')),
	},
	getters: {
		gettoken: state => {
			return localStorage.getItem("token");
		},
		getRole: state => {
			return state.userInfo.role;
		}
	},
	mutations: {
		//存储token
		settoken(state, token) {
			state.token = token;
			localStorage.setItem("token", token);
		},
		// 删除token
		removetoken(state) {
			localStorage.removeItem('token');
		},
		updatePublishActiveIndex(state, value) {
			state.path = value;
		},
		setUserInfo(state, userInfo) {
			state.userInfo = userInfo;
		},
	},
	actions: {
	},
	modules: {},

})